<html>
<header>
<?php
    session_start();
    if(isset($_POST['submit'])){
            include("includes/dbcon.php");
            $username = $_POST['username'];
            $pass = $_POST['password'];
            $salt= substr($username , 0 , 2);
            $enc_pass = crypt($pass ,$salt);
            $query = "SELECT * FROM users WHERE username = '{$username}' AND password ='{$enc_pass}'";
            $queryset = mysql_query($query,$con); 
            while($query_row=mysql_fetch_array($queryset)){
                $_SESSION['uname'] = $query_row['username'];
                $_SESSION['password'] = $query_row['password'];
            }  
            
        }
    if(isset($_SESSION['uname']) && $_SESSION['password']){
        header("location:home.php");
    
    }
?>
<title>Sign in | Drafts Store</title>

</header>
<body>
<form action="login.php" method="post">
<label for="uname">Username <input type="text" name="username"/></label><br/>
<label for="password">Password <input type="password" name="password"/></label><br/>
<label for="facebook_signIn">
<div id="fb-root"></div>
      <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : 'YOUR_APP_ID',
            status     : true, 
            cookie     : true,
            xfbml      : true
          });
        };
        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      </script>
      <div class="fb-login-button">Login with Facebook</div>
</label><br/>
<label for="twitter_signIn">Sign in with twitter</label><br/>
<input type="submit" name="submit" value="Sign in !"/>
</form>
</body>
</html>
